<% content_for :content do %>

  <!-- widget grid -->
  <section id="widget-grid" class="">
  
    <!-- row -->
    <div class="row">
  
      <!-- NEW WIDGET START -->
      <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
  
        <!-- Widget ID (each widget will need unique ID)-->
        <div class="jarviswidget jarviswidget-color-blueDark" id="wid-id-3" data-widget-editbutton="false" data-widget-colorbutton="false" data-widget-deletebutton="false">
          <!-- widget options:
          usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">
  
          data-widget-colorbutton="false"
          data-widget-editbutton="false"
          data-widget-togglebutton="false"
          data-widget-deletebutton="false"
          data-widget-fullscreenbutton="false"
          data-widget-custombutton="false"
          data-widget-collapsed="true"
          data-widget-sortable="false"
  
          -->
          <header>
            <span class="widget-icon"> <i class="fa fa-table"></i> </span>
            <h2>终端版本列表</h2>
  
          </header>
  
          <!-- widget div-->
          <div>
  
            <!-- widget edit box -->
            <div class="jarviswidget-editbox">
              <!-- This area used as dropdown edit box -->
  
            </div>
            <!-- end widget edit box -->
  
            <!-- widget content -->
            <div class="widget-body no-padding">
              <div class="widget-body-toolbar">
                
              </div>
              <table id="datatable_tabletools" class="table table-striped table-hover vertical-align-middle">
                <thead>
                  <tr>
                    <th>当前</th>
                    <th>发布</th>
                    <th>名称</th>
                    <th>版本</th>  
                    <th>文件大小</th>
                    <th>相关人</th>
                    <th>提交时间</th>
                    <th>更新时间</th>
                    <th>操作</th>
                  </tr>
                </thead>
                <tbody>
                <% @terminal_versions.each do |i| %>
                  <tr id='terminal-<%= i.id %>'>
                    <td>
                      <%- if i.release %>
                        <i class="fa fa-check"></i>
                      <% end %>
                    </td>
                    <td>
                      <%- if i.release %>
                        <i class="fa fa-check"></i>
                      <% end %>
                    </td>
                    
                    <td>
                      <%= link_to i.display_name, '#', class: "hint  hint--bottom", 'data-hint' => "备注: #{raw i.note}" %> 
                    </td>
                    <td>
                      <% if i.file.present? %>
                        <%= link_to i.version, i.file.url %>
                      <% else %>
                        <%= i.version %>
                      <% end %>
                    </td>
                    <td>
                      <%= number_to_human_size(i.file_size, precision: 2) %>
                    </td>

                    <td width=100>         
                      <%= i.staff_emails %>
                    </td>
                      <td width='100'><%= i.created_at.stamp("2013-03-12") %></td>
                      <td width='100'><%= i.updated_at.stamp("2013-03-12") %></td>
                      <td width='70'>
                      <%= link_to '编辑', edit_admin_terminal_version_path(i), remote: true if current_admin.can?(controller: "admin/terminal_versions", action: "edit") %>
                      <%= link_to "删除", admin_terminal_version_path(i), method: :delete, remote: true, confirm: '是否确定删除?' if current_admin.can?(controller: "admin/terminal_versions", action: "destroy") %>
                    </td>
                    </tr>
                  <% end %>
                </tbody>
              </table>
  
            </div>
            <!-- end widget content -->
  
          </div>
          <!-- end widget div -->
  
        </div>
        <!-- end widget -->
  
      </article>
      <!-- WIDGET END -->
  
    </div>
  
    <!-- end row -->
  
  </section>
  <!-- end widget grid -->
<% end %>

<% content_for :js do %>

  <script type="text/javascript">
  
  $(document).ready(function() {
    
    /* TABLE TOOLS */
    $('#datatable_tabletools').dataTable({
      "sDom" : "<'dt-top-row'Tlf>r<'dt-wrapper't><'dt-row dt-bottom-row'<'row'<'col-sm-6'i><'col-sm-6 text-right'p>>",
      "oTableTools" : {
        "aButtons" : [ 
            <% if current_admin.can?(controller: "admin/terminal_versions", action: "new") %>
            {
              "sExtends":    "text",
              "sButtonText": '<%= link_to "添加终端版本", new_admin_terminal_version_path, remote: true %>'
            }
            <% end %>
         ],
      },
      "bInfo": true,
      "fnInitComplete" : function(oSettings, json) {
        $(this).closest('#dt_table_tools_wrapper').find('.DTTT.btn-group').addClass('table_tools_group').children('a.btn').each(function() {
          $(this).addClass('btn-sm btn-default');
        });
      }
    });

  })

  </script>
<% end %>
